﻿using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Controls;

namespace AdjustInstallationHeight
{
	internal class ElementNeedMoveAnalyzer
	{
		public List<Element> LstElement
		{
			get
			{
				return this.m_lstElement;
			}
			private set
			{
				this.m_lstElement = value;
			}
		}

		public ElementNeedMoveAnalyzer(UIDocument uiDoc, List<BuiltInCategory> lstStrCategory)
		{
			this.LstElement = this.GetElements(uiDoc, lstStrCategory);
			if (this.LstElement.IsEmpty<Element>())
			{
				YJKMessageBox.Show("没有框选到需要调整的设备。");
			}
		}

		private List<Element> GetElements(UIDocument uiDoc, List<BuiltInCategory> lstStrCategory)
		{
			this.CategoryTransToId(lstStrCategory);
			ElementTypeFilter elementTypeFilter = new ElementTypeFilter(lstStrCategory);
			IList<Element> source = uiDoc.Selection.PickElementsByRectangle(elementTypeFilter, "请框选……");
			this.LstElement = (from n in source
			select n).ToList<Element>();
			return this.LstElement;
		}

		private List<int> CategoryTransToId(List<BuiltInCategory> lstStrCategory)
		{
			List<int> list = new List<int>();
			foreach (BuiltInCategory item in lstStrCategory)
			{
                list.Add((int)item);
			}
			return list;
		}

		private List<Element> m_lstElement = new List<Element>();
	}
}
